<?php

class Application_Model_DbTable_Coupon extends Application_Model_DbTable_DomainObject{
    
    protected $_name = 'uuch_coupon';
    
    public function getMapper() {
        return array('id','dateCreated','no','type','money','scope','discount','startTime','dateExpired','status','useTime','relevance','userType','password','userId','batchNo','name','common','useType');
    }
            
    /*
    * 根据用户名，状态获取当前总数
    * @param int $userid 用户序号
    * @param int $status 用户序号
    * @return int
    */
    public  function getItemCount($user,$status){

        $db = $this->getAdapter();

        if( $status ==-1){
            $result = $db->query('select count(*) from uuch_coupon where userid='.$user);
        }
        else{
            $result = $db->query('select count(*) from uuch_coupon where userid='.$user.' and status='.$status );
        }            
        $c = $result->fetchColumn();
        return $c;
    }
}